import { createSlice } from "@reduxjs/toolkit";
import type { PayloadAction } from '@reduxjs/toolkit'

interface IState {
  username:string,
  direction:'left' | 'right' | 'up' | 'down'
}
const initialState:IState = {
  username:'user~~',
  direction:'left'
}

const userSlice = createSlice({
  name:'user',
  initialState,
  reducers:{
    changeName(state,{ payload }:PayloadAction<string>){
      state.username = payload
    }
  }
})

export const { changeName } = userSlice.actions
export default userSlice.reducer